#include "bspSysTick.h"

static __IO u32 gTimeCount=0;
static __IO u32 delayValue=0;
u32 tick_reboot;
void bspSysTickInit(void)
{
	SysTick_Config(9000);
	SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
}

u32 millis(void)
{
	return gTimeCount;
}

void delay(u32 ms)
{
	delayValue=ms;
	while(delayValue);
}

__WEAK void Timer1msCallback(void)
{
	
}

void SysTick_Handler(void)
{
	gTimeCount++;
	if(delayValue) delayValue--;
	Timer1msCallback();
		tick_reboot++;
	if(tick_reboot>86400000)
	{
		tick_reboot = 0;
		NVIC_SystemReset();
	}
}